package org.mao.util;

public class Page {

	private Integer currentPage;
	private Integer totalPage;
	private Integer count;
	private Integer index;
	private Integer limit = 20;

	public Integer getIndex() {
		this.index = (this.getCurrentPage() - 1) * this.limit;
		return index;
	}

	public void setIndex(Integer index) {
		this.index = index;
	}

	public Integer getLimit() {
		return limit;
	}

	public void setLimit(Integer limit) {
		this.limit = limit;
	}

	public Integer getCurrentPage() {
		if (currentPage == null) {
			currentPage = 1;
		}
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		if (currentPage == null) {
			currentPage = 1;
		}
		this.currentPage = currentPage;
	}

	public Integer getTotalPage() {
		if(count==null){
			count=0;
		}
		totalPage = count / limit;
		if (count % limit != 0) {
			totalPage++;
		}
		return totalPage;
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

}
